//
//  CustomCellView_Goods.m
//  FlyingEagle
//
//  Created by Lj on 2017/6/5.
//  Copyright © 2017年 lj. All rights reserved.
//

#import "CustomCellView_Goods.h"

@interface CustomCellView_Goods()
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *priceLabel;

@end

@implementation CustomCellView_Goods


// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}


- (id)init {
    if (self = [super init]) {
        [self initView];
    }
    return self;
}

- (void)initView {
    self.imageView = [[UIImageView alloc]init];
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:@"ddd"] placeholderImage:[UIImage imageNamed:@"shichang_default"]];
    [self addSubview:self.imageView];
    [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.mas_centerY);
        make.height.width.offset(60);
        make.left.equalTo(self).offset(15);
    }];
    
    self.nameLabel = [[UILabel alloc]init];
    self.nameLabel.numberOfLines = 2;
    self.nameLabel.textColor = [UIColor blackColor];
    self.nameLabel.font = BHFont_Size_14;
    [self addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.imageView.mas_right).offset(10);
        make.right.equalTo(self.mas_right).offset(- 15);
        make.topMargin.equalTo(self.imageView.mas_topMargin).offset(3);
    }];
    
    self.priceLabel = [[UILabel alloc]init];
    self.priceLabel.textColor = [UIColor colorWithHexString:@"F81A2A"];
    self.priceLabel.font = BHFont_Size_14;
    [self addSubview:self.priceLabel];
    [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leftMargin.equalTo(self.nameLabel.mas_leftMargin);
        make.top.equalTo(self.nameLabel.mas_bottom).offset(5);
        make.right.equalTo(self.mas_right).offset(- 15);
        
    }];
}

- (void)setDataDic:(NSDictionary *)dataDic {
    if (![BHSettingUtil dataAndStringIsNull:dataDic]) {
        [self.imageView sd_setImageWithURL:[NSURL URLWithString:dataDic[@"goods_image"]] placeholderImage:[UIImage imageNamed:@"shichang_default"]];
        self.nameLabel.text = dataDic[@"goods_name"];
        self.priceLabel.text = dataDic[@"goods_price"];
    }
}

@end
